package com.znf.config;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;

@NoArgsConstructor
@Data
public class CustomUserDetails implements UserDetails , Serializable {

    public static String USER_ID = "userId";

    public static String USER_NNAME = "usernName";

    public static String NICK_NAME = "nickName";

    private Long userId;

    private String username;

    private String nickName;

    private String password;

    private Set<GrantedAuthority> authorities;


    public CustomUserDetails(Set<GrantedAuthority> authorities) {
        this.authorities = Collections.unmodifiableSet(authorities);
    }


    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return this.authorities;

    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public String getUsername() {
        return username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
